package com.example.meterialproject.activitys.transition.demo4

import android.os.Bundle
import android.view.View
import com.example.meterialproject.base.BaseActivity
import com.example.meterialproject.databinding.ActivityTransitionDemo4Binding
import com.example.meterialproject.exts.addRandomColorView
import com.example.meterialproject.exts.click
import com.example.meterialproject.exts.convert


/**
 *
 * @ClassName: TransitionDemo4Activity
 * @Author: android 超级兵
 * @CreateDate: 4/27/22$ 7:08 PM$
 * TODO view to view
 */
class TransitionDemo4Activity : BaseActivity<ActivityTransitionDemo4Binding>() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // 卡片一点击监听
        binding.card1.click {
            it.convert(binding.parentView, binding.openView.parentView)
        }
        // 卡片二点击监听
        binding.card2.click {
            it.convert(binding.parentView, binding.openView.parentView)
        }

        binding.openView.parentView.click {
            if (binding.card1.visibility == View.INVISIBLE) {
                it.convert(binding.parentView, binding.card1)
            } else {
                it.convert(binding.parentView, binding.card2)
            }
        }

        // floatButton 点击
        binding.floatBtn.click {
            it.convert(binding.parentView, binding.openView2.parentView)
        }

        //
        binding.openView2.parentView.click {
            it.convert(binding.parentView, binding.floatBtn)
        }

        // 给linear赋值
        binding.openView2.linear.addRandomColorView(isCallBack = false)
    }
}